#include "threadingmanager.h"

ThreadingManager::ThreadingManager(QObject *parent)
    : QObject{parent}
{
    connect(this, &ThreadingManager::ping, this, &ThreadingManager::pong);
}

void ThreadingManager::start()
{
    stop();
    QObject *worker = initialization();
    connect(&m_thread, &QThread::finished, worker, &QObject::deleteLater);
    worker->moveToThread(&m_thread);
    m_thread.start();
}

void ThreadingManager::stop()
{
    if (m_thread.isRunning()) {
        m_thread.quit();
        m_thread.wait();
    }
}
